<?php
header("content-type:text/html;charset=utf-8");
session_start();
if(isset($_POST['sub'])){
    $id=$_POST['name'];//用户名
    $ps=$_POST['psw'];//密码
//    $em=$_POST['email'];//邮件

    //将用户名作为session_id
    $_SESSION['user'][$id]=$id;
    $_SESSION['user'][$ps]=$ps;
//    $_SESSION[$em]=$em;

    echo '
    <script language="JavaScript">
        alert("注册成功，正在跳转...");
        window.location.href="./login.php";
    </script>';
}else{
    echo '
    <script language="JavaScript">
        alert("用户信息不完整");
        window.location.href="./register.php";
    </script>';
}
?>